﻿<!doctype html>
<html>
<!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>投诉建议</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/common.js"></script>
<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery.pager.js"></script>
<script type="text/javascript" src="../js/amrAudioPlayer.js"></script>
	<script type="text/javascript" src="../js/left.js"></script>
<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script>
<link href="../css/validator3.css" type="text/css" rel="stylesheet" />
<link href="../css/style.css" type="text/css" rel="stylesheet" />

<link href="shadowbox/shadowbox.css" rel="stylesheet" />
<script type="text/javascript" src="shadowbox/shadowbox.js"></script>
<script type="text/javascript" src="../js/ac_quicktime.js"></script>
<script type="text/javascript" src="../js/doubleDate2.0.js"></script>
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->

<script type="text/javascript">
	/*全局状态变量*/
	var _pageIndex = 1; //当前页码，默认为 0
	var _pageCount = 0; //每页显示记录数量，还未使用
	var _flag = 0; //标识当前是更新还是添加，0标示添加，1标示更新
	$(function() {
		
		$('.doubledate').kuiDate({
			className : 'doubledate',
			isDisabled : "1" // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
		});
		var flag=getIdByName("flag");
		if(flag==2){
			var cusName=getIdByName("cusName")
			var dtBegin= getIdByName('dtBegin');
			var dtEnd= getIdByName('dtEnd');
			var status=getIdByName('status');
			cusName= decodeURI(cusName);
			$("#openName").val(cusName);
			$("#dtBegin").val(dtBegin);
			$("#dtEnd").val(dtEnd);
			$("#status").val(status);
			var p=getIdByName('pageIndex');
			if(IsNotEmpty(p)){
			_pageIndex=p;	
			}
			search();
		}
		
		initImage();
		var startDate = $('#dtBegin').val(getToday());
		var endDate = $('#dtEnd').val(getToday());
	});

	//初始化图片查看组件
	function initImage() {
		Shadowbox.init();
		window.openImage = function(url) {
			Shadowbox.open({
				content : url,
				player : 'img'
			});
		}
	}


	function search() {
		var status = $('#status').val();
		var startDate = $('#dtBegin').val();
		var endDate = $('#dtEnd').val();
		var openName = $('#openName').val();
		$.ajax({
			type : "get",
			async:false,
			data : {
				'status' : status,
				'dtBegin' : startDate,
				'dtEnd' : endDate,
				'cusName' : openName
			},
			url : "../complnt/find/complaintList/"+(_pageIndex-1)+"/10",
			success : function(data) {
				var rst = JSON.parse(data);
				 if(IsEmpty(rst)){
						art.dialog({fixed:true, lock: true,content:"查询出错",icon:'error',ok:true});	
						return false;
						}
						if(rst.state==0){
							printDataToPage(rst);	
							if(rst.result.len > 0){
								 var shu = rst.result.len;
								 _pageCount = Math.ceil(shu/10);
							 	 $("#NoResult").hide();
							}else{
								$("#NoResult").show();
								_pageCount=0;

							}
							 	$("#sup").html("共"+rst.result.len+"条");	
							 
							 $("#pager").pager({ pagenumber: _pageIndex, pagecount: _pageCount, buttonClickCallback: function(index){_pageIndex=index;search();} });
	
						}else if(rst.state==1){
							art.dialog({fixed:true, lock: true,content:rst.msg,icon:'error',ok:true});	
						}else{
							checkStateShowErrorMsgAndDealResult(data);
						}
			}
		});
	
		
		}
	

	function printDataToPage(message) {
		$("#tbody").empty();
		var len = message.result.len;
		for ( var i = 0; i < len; i++) {
			var billFrom = getHtmlString(getHeadIndexValue(i, message, 'billFrom'))  ;
			var cmpltTypeName =getHtmlString( getHeadIndexValue(i, message, 'cmpltTypeName'));
			var cmpltDate = getHtmlString(getHeadIndexValue(i, message, 'cmpltDate'));
			var title = getHtmlString(getHeadIndexValue(i, message, 'title'));
			var custName = getHtmlString(getHeadIndexValue(i, message, 'custName'));
			var staName = getHtmlString(getHeadIndexValue(i, message, 'staName'));
			var phone = getHtmlString(getHeadIndexValue(i, message, 'phone'));
			var state= getHtmlString(getHeadIndexValue(i, message, "status"));
			var content= getHtmlString(getHeadIndexValue(i, message, "content"));
			var voideURl= getHtmlString(getHeadIndexValue(i, message, "voiceUrl"));
			var imgeUrl= getHtmlString(getHeadIndexValue(i, message, "imageUrl"));
			var h="";
			 h="<input class=\"common_btn\" type=\"button\" value=\"查看\" onclick=\"toUpdate("+getHtmlInt(getHeadIndexValue(i, message, "id"))+")\">"

			if(state!=2){	
				 h+="<input class=\"common_btn\" style='background-color:#B32400;' type=\"button\" value=\"已处理\" onclick=\"cl("+getHtmlInt(getHeadIndexValue(i, message, "id"))+")\">"
			}
			 var musicEvent = '';
				if (IsNotEmpty(voideURl)) {
					var musicEvent ="<a id='amr"+i+"' href='#' onclick=amrAudioPlay('"+voideURl+"','amr"+i+"')><font style='text-decoration:underline; color: green;'>播放</font></a>";
				}
				var imageTd = '';
				if (IsNotEmpty(imgeUrl)) {
					imageTd="<a href='#' style='text-decoration:underline; color: green;' onclick=openImage('"+imgeUrl+"')>查看</a>";
				}
			var $tr = $("<tr><td>" + billFrom + "</td>" + "<td>" + cmpltTypeName
					+ "</td>" + "<td>" + cmpltDate + "</td>"
					+ "<td>" + title+"</td><td>"+content+"</td><td>" + imageTd+"</td><td>"+ musicEvent
					+ "</td><td>" + custName + "</td>" + "<td>"
					+ phone + "</td>" + "<td>" + staName
					+ "</td><td>"+h+"</td></tr>");
			$("#tbody").append($tr);
		}
		$("#sup").text('  共 ' + len + ' 条');
	}

	function toUpdate(id){
		window.location.href='makeComplain.html?id='+id+"&dtBegin="+$("#dtBegin").val()+"&dtEnd="+ $("#dtEnd").val()+"&status="+$("#status").val()+"&cusName="+$("#openName").val()+"&pageIndex="+_pageIndex;
	}
	function cl(id){
		art.dialog({fixed:true, lock: true,content:"确认已处理该条数据？",icon:'warning',ok:function(){toUpdateStatus(id)},cancel:true});	
	
	}
	
	function toUpdateStatus(id){
		var heads=new Array("status","id");
		var datas=new Array("2",id);
		var parser = new Object();
		var jsonParserStr = null;
		if (IsNotEmpty(datas)){
			addToParser(heads, datas, "edit" , parser);
			jsonParserStr =  JSON.stringify(parser);
		}
		
		$.post("../complnt/edit/editStatus",{"data":jsonParserStr}, function(data) {
			var dt = JSON.parse(data);	
					 if(IsEmpty(dt)){
							art.dialog({fixed:true, lock: true,content:"处理出错",icon:'error',ok:true});	
					return false;
					}
					if(dt.state==0){
						search();
					art.dialog({fixed:true, lock: true,content:"处理成功",icon:'succeed',ok:true});	
					}else if(dt.state==1){
						art.dialog({fixed:true, lock: true,content:dt.msg,icon:'error',ok:true});
					}else{
						checkStateShowErrorMsgAndDealResult(data);
					}
			
		});
	}
	
	function  downRescouse(){
		var status = $('#status').val();
		var startDate = $('#dtBegin').val();
		var dtEnd = $('#dtEnd').val();
		var openName = $('#openName').val();
		var param='status='+status+'&dtBegin='+startDate+"&dtEnd="+dtEnd+"&cusName="+openName+"&downType=12";		
		window.location.href="../csvdown/down/csv/down?"+param

	}
	function toAddMan(){
		var status = $('#status').val();
		var startDate = $('#dtBegin').val();
		var dtEnd = $('#dtEnd').val();
		var openName = $('#openName').val();
		var param ="&status="+status+"&dtBegin="+startDate+"&dtEnd="+dtEnd;
		window.location.href='addComplain.html?menu='+getIdByName("menu")+"&submenu="+getIdByName("submenu")+param
	}
</script>
</head>
<body>
	<!-- 用来播放音乐，不会影响页面布局 -->
	<div id="jquery_jplayer"></div>
	<div id="yinying"></div>
	<!-- InstanceBeginEditable name="EditRegion3" -->
	<div class="container" id="container">
		<div class="container_R fr">
			<div class="place">投诉建议</div>
			<div class="member_search">
				<p>
					<label>
					<span>昵称或姓名：</span> <input type="text" id="openName"
						class="absoluteTxt"> </label><span>起始日期：</span>
					<input type="text" readonly class="doubledate ipticon" id="dtBegin" />
					<span>截止时间：</span> <input type="text" readonly
						class="doubledate ipticon" id="dtEnd" />
				</p>
				<p>
					<span>状态：</span>
							 <select id="status">
							 	<option value="">所有</option>
								<option value="0">未处理</option>
								<option value="1">处理中</option>
								<option value="2">已处理</option>
							</select> <input type="button" value="查询"
						class="btn" onclick="search()">
				</p>
			</div>
			<table width="100%" class="member_list" cellpadding="0"
				cellspacing="1" border="0" id="memberList">
				<caption>
					<strong>投诉 建议列表<span id="sup"></span>
					</strong><a href="javascript:void(0)" onclick="downRescouse()">导出数据</a><input onclick=" toAddMan()" type="button" class="common_btn" value="添加">
				</caption>
				<thead>
					<tr>

						<th>来源</th>
						<th>类型</th>
						<th>时间</th>
						<th>主题</th>
						<th>内容</th>
						<th>图片</th>
						<th>音频</th>
						<th>姓名</th>
						<th>联系电话</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="tbody">
				</tbody>
			</table>
			<div id="pager" style="float: right;"></div>
		</div>
		<div class="fc"></div>
	</div>
	<!-- InstanceEndEditable -->
	<script type="text/javascript" src="../js/header.js"></script>
	<script type="text/javascript" src="../js/footer.js"></script>
	<script type="text/javascript">
		clearThis("absoluteTxt");
		showTab(4, 10);
	</script>
</body>
<!-- InstanceEnd -->
</html>
